The questions: Drive Train & color should run only if you choose "Porsche" type. But it runs with any car. What should I do ?
var car = prompt("Which Car would you like to drive?").toLowerCase(); //prompt will converted to lower case..that's cool..ar driveType = prompt("Would you prefer 2ND or 4WD drive ?").toLowerCase();
var carColor = prompt("Prefer Black,Red, Silver or another color?").toLowerCase();
switch (car){
    case 'porsche':
        console.log("Porsche, the choice for German Car lovers, The persicion, the technology and the perfect allround car");
        if (carColor==="black"&&driveType==="4wd"){
            console.log("Just my type of car!");
           
        }
        else if (carColor==="red"||carColor==="silver"){
            console.log("Great choice");
           
        }
        else{
            console.log("We Need to check if this color is available for prompt delivery");
        }
        break;
    case 'ferrari':
        console.log("Ferrari, The Italian Choice for the Sport luxury car lovers.. with the horse upfront");
        break;
    case 'lamborghini':
        console.log("Lamborghini, the Raging bull ! Sharp design and kicking engine!");
        break;
    default:
        console.log("I don't recorgnise this brand.");
        break;
}

1 תשובות

avatar ענה x-dream ב 20 לאוקטובר 2015 #

בסדר הבנתי מה קרה הקוד שלי בסדר פשוט צריך להזיז את השורות של האינפוט לבלוק של
case : porsche